package cn.servlet;

import cn.dao.StaffDao;
import cn.dao.StaffDaoImpl;
import cn.entity.Staff;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

@WebServlet("/search")
public class SearchServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        String keyword = req.getParameter("keyword");
        StaffDao dao = new StaffDaoImpl();
        List<Staff> staff = dao.searchName(keyword);
        req.setAttribute("staff", staff);
        req.getRequestDispatcher("staff_list.jsp").forward(req, resp);
    }
}
